package Com.amit.Collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

class Amit implements Comparable
{
	int id;
	String name;
	int age;
	
	public Amit(int id, String name, int age) {
		super();
		this.id = id;
		this.name = name;
		this.age = age;
	}

	@Override
	public int compareTo(Object obj) {
		Amit a=(Amit)obj;
		
		if(age==a.age)
		{
			return 0;
		}
		
		else if(age>a.age)
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}	
	
}

public class Lab12 {

	public static void main(String[] args) {
		
		ArrayList al=new ArrayList();
		al.add(new Amit(1,"amit",230));
		al.add(new Amit(2,"amit3",23));
		al.add(new Amit(3,"amit3",231));
		al.add(new Amit(3,"amit0",2));
		
		Collections.sort(al);
		
		Iterator itr=al.iterator();
		
		
		while(itr.hasNext())
		{
			Amit a=(Amit)(itr.next());
			System.out.println(a.id+" "+a.name+" "+a.age);
		}
		
		

	}

}
